package com.unicom.room.controller;

import com.unicom.room.common.JsonResult;
import com.unicom.room.model.IncomeStatisticsVo;
import com.unicom.room.model.Room;
import com.unicom.room.model.roomtypeVo;
import com.unicom.room.service.IncomeStatisticsService;
import com.unicom.room.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;


@RestController
@RequestMapping("/hotelMgmt/incomeStatistics")
public class IncomeStatisticsController {

	@Autowired
	private IncomeStatisticsService incomeStatisticsService;
	@Autowired
	RoomService roomService;

	/**
	 * 统计当年的每月收入
	 */
	@RequestMapping(value = "/getIncome", method = RequestMethod.GET)
	public JsonResult getIncome() {
		List<IncomeStatisticsVo> monthStatistics = incomeStatisticsService.getIncome();
		return new JsonResult("00000", monthStatistics);
	}

	/**
	 * 房态统计
	 */
	@RequestMapping(value = "/getRoomList", method = RequestMethod.GET)
	public JsonResult getRoom() {
		List<roomtypeVo> typeList = incomeStatisticsService.getRoomTypeList();
		int sum = 0;
		for(roomtypeVo r : typeList)
			sum +=r.getCount();
		List<Room> rooms = roomService.listRooms();
		int rest = rooms.size() - sum;
		roomtypeVo room = new roomtypeVo();
		room.setStatus(-1);
		room.setCount(rest);
		typeList.add(room);
		return new JsonResult("00000", typeList);
	}

}
